/*
 * @Description: 获取分页
 * @Date: 2022-12-27 21:28:26
 * @Author: lizhiqiang
 */
import { useEffect, useState } from "react"
export default function useFetchData ( fetchMethod: any ) {
    const [ result, setResult ] = useState<Array<any>>( [] );
    const getResult = async () => {
        const { code, data } = await fetchMethod( {
            limit: 1000,
            page: 1
        } );
        if ( code === 200 ) {
            setResult( data.list )
        } else {
            setResult( [] )
        }
    }
    useEffect( () => {
        getResult()
    }, [] )
    return result;
}